class Program < ActiveRecord::Base
  has_paper_trail :version => :paper_trail_version, :versions => :paper_trail_versions
  attr_protected
  belongs_to :city_channel
  belongs_to :television

  delegate :logo, to: :television
  delegate :name, to: :television
  delegate :play_url, to: :television

  validates :city_channel_id, :television_id, :sid, :freq, :presence => true

  default_scope where("city_channel_id is not NULL and television_id is not null")

  %w{dtmb cmmb dvb}.each do |cc|
    define_method cc do
      self.city_channel.mode == cc ? cc.upcase : ""
    end
  end

end
